import com.mchange.v2.c3p0.ComboPooledDataSource;
import org.apache.commons.dbcp.BasicDataSourceFactory;
import org.junit.Test;

import javax.sql.DataSource;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;

public class Dbcp {
    @Test
    public void DbcpTest() throws Exception {
        InputStream inputStream = Dbcp.class.getClassLoader().getResourceAsStream("dbcp.properties");
        Properties prop = new Properties();
        prop.load(inputStream);
        //获取数据源(连接池)
        DataSource dataSource = BasicDataSourceFactory.createDataSource(prop);
        Connection connection = dataSource.getConnection();
        System.out.println(connection);

    }

    @Test
    public void c3p0Test() throws Exception {
        ComboPooledDataSource dataSource = new ComboPooledDataSource();
        Connection connection = dataSource.getConnection();
        System.out.println(connection);
    }
}
